package router

import (
	captcha "Short_chain_cats/captcha/puzzle_captcha"
	"Short_chain_cats/middleware"
	"Short_chain_cats/user/controller"

	"github.com/gin-gonic/gin"
)

func RegisterUserRoute(v1 *gin.RouterGroup) {
	// 公共路由
	userCtrl := controller.UserController
	captcha.LoadBackgroudImages("./captcha/images/puzzle_captcha/backgroud")
	captcha.LoadBlockImages("./captcha/images/puzzle_captcha/block")
	v1.POST("/captcha/get", controller.GetCaptcha)     //生成验证码图片并返回
	v1.POST("/captcha/check", controller.CheckCaptcha) //校验用户滑动位置
	v1.POST("/register", userCtrl.Create)
	v1.POST("/login", userCtrl.Login)
	v1.POST("/forgetPassword", userCtrl.ForgetPassword)
	v1.POST("/refreshToken", userCtrl.RefreshToken)
	//监控部分,使用redis计数
	v1.GET("/userCount", userCtrl.UserCount)
	v1.GET("/shortChainCount", userCtrl.ShortChainCount)
	//用户注册变化情况
	v1.POST("/userRegisterCount", userCtrl.GetDailyRegisterCounts)
	v1.POST("/shortChainGenerateCount", userCtrl.ShortChainGenerate)
	v1.Use(middleware.JWTAuth())
	v1.Use(middleware.CasbinMiddleware())
	v1.Use(middleware.SecurityMiddleware())
	{
		v1.POST("/uploadPicture", userCtrl.UploadPicture)
		v1.POST("/sendEmailCode", userCtrl.SendEmailCode)
		v1.POST("/updateUserInfo", userCtrl.UpdateUserInfo)
		v1.POST("/updateUserPassword", userCtrl.UpdateUserPassword)
	}
}

func RegisterManagerRoute(v1 *gin.RouterGroup) {
	// 公共路由
	userCtrl := controller.UserController
	v1.Use(middleware.JWTAuth())
	v1.Use(middleware.CasbinMiddleware())
	v1.Use(middleware.SecurityMiddleware())
	{
		v1.POST("/getUserList", userCtrl.GetUserList)
		v1.PUT("/editUser", userCtrl.EditUser)
		v1.DELETE("/deleteUsers", userCtrl.DeleteUser)
		v1.POST("/exportExcel", userCtrl.ExportExcel)
	}
}
